<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>防抖</title>
</head>
<body>
   <input id="button" type="button" value="点击">
</body>
<script type="text/javascript">
    var button = document.getElementById("button");
    button.addEventListener("click",decounce(click,1000))
    function click() {
        console.log("我被点击了");
    }
    function decounce(fn,time) {
        var timeout = null;
        return function () {
            clearTimeout(timeout);
            timeout = setTimeout(function () {
                fn.apply(this,arguments)
            },time)
        }
    }
</script>
</html>